<template>
<div>
    用户名：<el-input v-model="resform.name" placeholder="请输入用户名"></el-input>
    <el-button @click="submit">登录</el-button>
</div>
</template>

<script setup>
import { ref } from 'vue'
import http from '../../http'
import { useRouter } from 'vue-router'
const router = useRouter()
const resform = ref({ name: '' })
const submit = () => {
    http.post('logins/', resform.value).then(res => {
        if (res.data.code == 200) {
            console.log('登录成功');
            localStorage.setItem('token', res.data.token)
            localStorage.setItem('menulist', JSON.stringify(res.data.menulist))
            localStorage.setItem('permmison', JSON.stringify(res.data.permmison))
            router.push('/admin')
        }else{
            console.log('登录失败');
        }
    }).catch(err => {
        console.log(err);
    })
}
</script>

<style lang="scss" scoped>

</style>